import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Timer here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Timer extends Actor
{
    
    private long milisFin;
    private long milisInicio;
    private long duracion;
    /**
     * Constructor for objects of class Timer
     */
    public Timer()
    {
        milisInicio = System.currentTimeMillis(); 
        duracion=0;
    }
    
    public void start() 
    {
        milisInicio = System.currentTimeMillis();      
    }
    
    public void transcurrido()
    {        
        milisFin = System.currentTimeMillis();     
        duracion=milisFin-milisInicio;
    }
    
    public void tiempo(int t) 
    {
       getImage().drawString(""+duracion+"",5,5);
    
       while(duracion>=t)
       {
           transcurrido();
       }
       
    }
}
